package com.bit.demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-02-08
 * Time: 23:03
 */
class Animal{
    public String name = "hello";
    public int age;

    public Animal(String name,int age){
        eat();
        this.name = name;
        this.age =age;
    }
    public void eat(){
        System.out.println(name + "正在吃");
    }
}

class Dog extends Animal {
    public Dog(String name,int age){
        super(name,age); //调用父类带有两个参数的构造方法
    }

    @Override
    public void eat(){
        System.out.println(name+"在吃骨头");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("小狗",20);
    }
}
